<?php
//$Id: action.php 460 2012-07-09 08:27:03Z tomqin@gmail.com $

/**
 * Action 类
 *
 * @copyright       Copyright (C) 2010-2012 ARESCMS Inc.
 * @author          TomQin <tomqin@gmail.com>
 * @license         http://www.arescms.cn/license/
 * @package Core
 */

class OrderAction extends Action{
    protected $route  = 0;
    protected $action = '';
    protected $method = '';
    protected $params = null;
    protected $cityid = 0;

    //@覆盖：初始化（程序调用）
    protected function init(){}

    //@覆盖：初始化
    public function initialize($action, $param1, $param2){
        $this->action = $action;
        if($this->route){
            $this->method = $param2;
            $this->params = $param1;
        }else{
            $this->method = $param1;
            $this->params = $param2;
        }

        if(empty($this->method)) $this->method = 'index';

        $this->cityid = App::getCityId();

        $this->init();
    }

    //@执行：实际调用方法
    final public function process(){
        $this->setVar('action', $this->action);

        if(method_exists($this, 'on'.$this->method)){
            call_user_func(array($this, 'on'.$this->method));
        }elseif(method_exists($this, 'onDefault')){
            call_user_func(array($this, 'onDefault'));
        }else{
            exit('The method `' .$this->action.'::'.$this->method. '` is not exists!');
        }
    }

    protected function setVar($key, $var){
        View::setVar($key, $var);
    }

    protected function render($tpl){
        View::addView($tpl);
        View::display();
    }

    function seoContent(){
        $title = $keywords = $description = '';
        @list($title, $keywords, $description) = func_get_args();

        $cityname    = App::getCityName();
        $cityperfix  = App::getCityPerfix();
        $title       = str_replace('{CITY}', $cityname, $title.' - |速定客_{CITY}速订客，预订美好生活！');
        $keywords    = str_replace('{CITY}', $cityname, preg_replace('/[\|_ -,]/', ',', $title.$keywords));
        $description = str_replace('{CITY}', $cityname, isset($description) ? $description : $title);

        View::setVar('cityname', $cityname);
        View::setVar('cityperfix', $cityperfix);
        View::setVar('cityurl', $cityperfix.".sudingke.com");
        View::setVar('title', $title);
        View::setVar('keywords', $keywords);
        View::setVar('description', $description);
    }
}

?>